package com.af.red;

import java.sql.SQLException;

import net.sf.json.JSONObject;

import org.apache.log4j.Logger;

import com.af.common.DBHelper;
import com.af.common.Log4jXmlConfig;

public class AddRedPacks {
	Logger LOG = Log4jXmlConfig.getInstance().returnLogger(AddRedPacks.class);
	/**
	 * 增加红包记录
	 * @param ri
	 * @param creatDate
	 * @return
	 */
	public void addRedToMember(RedItem ri,int codeType){
		DBHelper dh = DBHelper.getInstance();
		String sql = "{call addRedPacks(?,?,?,?,?,?)}";
		Object args[] = new Object[6];
		args[0]=ri.getOrderId();
		args[1]=ri.getRedFee();
		args[2]=ri.getUserName();
		args[3]=ri.getRemarks();
		args[4]=ri.getCreateTime();
		args[5]=codeType;
		int count=0;
		try {
			count = dh.update(sql, args);
			LOG.info("派发红包状态["+count+"]"+JSONObject.fromObject(ri));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			LOG.error("派发红包失败"+JSONObject.fromObject(ri),e);
		}finally{
		dh.close();
		}
	}
}
